# Stage 1: Build with Maven
FROM maven:3.8.4-openjdk-8 AS build-with-maven
RUN mkdir ./${artifactId}
COPY / ./${artifactId}/
WORKDIR ./${artifactId}/
RUN mvn clean package
# Stage 2: Run App
FROM openjdk:8 AS run-app
RUN mkdir ./${artifactId}
# Copy Artifact from Stage 1
COPY --from=build-with-maven ./${artifactId}/src/main/resources/ ./${artifactId}/src/main/resources/
COPY --from=build-with-maven ./${artifactId}/target/${artifactId}-${version}.jar ./${artifactId}/
CMD java  -jar ./${artifactId}/${artifactId}-${version}.jar --spring.profiles.active=${SPRING_PROFILES_ACTIVE}